<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>注册</title>
		<!--标准mui.css，公共样式-->
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/get_pwdCode.css"/>
		<link rel="stylesheet" type="text/css" href="../css/public.css" />
	</head>
	<body class="bg_white">
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left color6"></a>
		    <h1 class="mui-title color6">注册</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row m_b16 phone">
					<input type="number" id="j_phone" class="mui-input-clear color3" placeholder="手机号"/>
					<button type="button" class="mui-btn mui-btn-green mui-btn-outlined verifyCode w100px" id="get_code">获取验证码</button>
				</div> 
				<div class="mui-input-row m_b20">    
					<input type="number" id="j_code" class="mui-input-clear verifyCode color3" placeholder="输入验证码">
				</div>
				<div class="mui-input-row m_b20">    
					<input type="password" id="j_pwd" class="mui-input-clear color3" placeholder="设置登录密码">
				</div>
				<div class="mui-input-row mui-checkbox mui-left sp_row">
				  <label class="font14 color6 w_auto">点击注册完成即表示同意</label><a href="javascript:;" onclick="tool.openNewPage('user_agreement.html')" class="colorP font14">用户协议</a>
				  <input name="checkbox1" type="checkbox" id="checkbox1">
				</div>
				<button type="button" class="mui-btn mui-btn-green bg_green btn-green w100 m_t40 p_tb11_lr15 font16 bg_P b_r8" id="j_next">注册完成</button>
			</form>
		</div>
	</body>
	<!-- Mui core JavaScript-->
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/appconfig.js"></script>
	<script type="text/javascript" src="../js/jquery-2.2.4.min.js"></script>
	<script>
		mui.init({
	        swipeBack: true //启用右滑关闭功能
	   });	
//	   var change=false;
		//当用户在输入手机号时进行判定，如果手机号正确则让"验证码"按钮可用
		$("#j_phone").on("keyup",function (){
			if(tool.validatePhone($(this).val())){
				$(".verifyCode").removeClass("can-not-use").addClass("active");
			}
		});
		//"验证码"按钮点击后所处理业务
		$("#get_code").on("tap",tool.getVerifyCodeCountDown({
			callBack: function (){
				phone = $('#j_phone').val();
				mui.ajax(webRoot+'?s=/App/Username/verifiDriver',{
					data:{
						account:$('#j_phone').val(),
					},
					type:'post',
					success:function(data){
						code = $.parseJSON(data);
					alert(2222);
					},
					error:function(data){
						alert(1111);
					}
				});
			},
			isPhone:true,
			getPhone: function (){
				return document.getElementById("j_phone").value;
			},
			phoneCallBack: function (){
				mui.toast('手机号码不正确！');
			},
			unabledClass: "can-not-use"
		}));
//		$('#checkbox1').on('tap',function () {
//          change=true;
//     });
		//当用户点击"注册"按钮时所处理业务
		$("#j_next").on("tap",function (){
			var pwd = $("#j_pwd").val();
			if(!tool.validatePhone($("#j_phone").val())){
				mui.toast("手机号码输入不正确！");
				return;
			}
			if(!tool.validatePasswrd(pwd)){
				mui.toast("密码输入不正确！密码必须为6位的字母、数字、下划线的任意组合！");
				return;
			}
			if(phone!=$('#j_phone').val()){
				mui.toast("输入的手机号码与获取验证码的手机号码不一致！");
				return;
			}
			if(code.data.codes!=$('#j_code').val()){
				mui.toast("验证码不正确！");
				return;
			}
//			if(!change){
//			    mui.toast("请同意用户协议");
//			    return;
//			}
			mui.ajax(webRoot+'?s=/App/Username/userRegister',{
				data:{
					account:phone,
					password:$('#j_pwd').val(),
				},
				type:'post',
				success:function(data){
//					aaa = $.parseJSON(data);
					if(code.code == 200){
						mui.toast('注册成功');
					}
				},
				error:function(data){
					alert(data);
				}
				});
			tool.openNewPage('login.html');
		});
	</script>
</html>